%% Author: 77
%% Created: 2011-7-5
%% Description: TODO: Add description to fetch_node_resouce_cmd
-module(fetch_node_resource_cmd).
-author(kanghua ).  
-email(kanghua151@msn.com).  
-date("2011.07.06").  
%%
%% Include files
%%

%%
%% Exported Functions
%%
-export([handle/3]).

%%
%% API Functions
%%


handle(Content,From,State) ->
	io:format("handle info ~p ~p ~p ~p ~n",[?MODULE,Content,From,State]), %% debug info
	case check_parm(Content) of 
		 true -> 
			 io:format("check parm pass ~n"),
		     {Node} = Content,
			 io:format("node info ~p ~n",[Node]), %% debug info
             case gen_server:call({node_server,Node},{fetch_node_resource,{Node}},1000) of
				  {error,Reason} ->
				 	   gen_server:reply(From, {error,resource_get_fail}),
                       error;
			      {ok,Resource}  ->  
%					   [Resource1] = Resource,
 				  	   io:format("node resource ~p ~n",[Resource]), %% debug info
	         		   gen_server:reply(From, {ok,Resource}),
			 		   io:format("reply over ~n"), %% debug info
            		   ok
             end;
		 false -> 
			 gen_server:reply(From,{error,err_param}),
             false
    end.
	
%%
%% Local Functions
%%

check_parm(Content)->
	true.
